<script setup>
import { ref } from 'vue'
import FileSelect from '../components/FileSelect.vue'

let page = 'waterMark'
let msg = ref('')
let position = ref({ val: 'southeast' })
let formatsAry = [
  {
    name: '左上角',
    val: 'northwest'
  },
  {
    name: '上方中间',
    val: 'north'
  },
  {
    name: '右上角',
    val: 'northeast'
  },
  {
    name: '左侧中间',
    val: 'west'
  },
  {
    name: '中心',
    val: 'center'
  },
  {
    name: '右侧中间',
    val: 'east'
  },
  {
    name: '左下角',
    val: 'southwest'
  },
  {
    name: '下方中间',
    val: 'south'
  },
  {
    name: '右下角',
    val: 'southeast'
  }
]
let waterLogo = ref('')

function fileSelect() {
  const select = window.service.openSelect()
  if (select && Array.isArray(select)) {
    waterLogo.value = select[0]
  }
}
</script>
<template>
  <div class="sets-wrapper">
    <!--    <h5>水印文字</h5>-->
    <div class="params-set">
      <!--      <div class="item-param">-->
      <!--        <van-field v-model="msg" placeholder="输入水印文字" style="padding: 0" />-->
      <!--      </div>-->
      <div class="item-param">
        <van-button v-if="!waterLogo" type="primary" @click="fileSelect">选择水印logo</van-button>
        <van-image v-else width="100" height="100" fit="contain" :src="waterLogo" />
      </div>
      <div class="item-param">
        <h5>水印位置：</h5>
        <van-radio-group v-model="position.val" direction="horizontal">
          <van-radio
            :name="item.val"
            v-for="(item, index) in formatsAry"
            :key="index"
            style="margin-bottom: 15px"
            >{{ item.name }}
          </van-radio>
        </van-radio-group>
      </div>
    </div>
  </div>
  <div class="files-wrapper flex1">
    <FileSelect :page="page" :msg="msg" :position="position.val" :waterLogo="waterLogo" />
  </div>
</template>
<style scoped>
.sets-wrapper {
  width: 35vw;
  padding: 10px 15px;
}

.item-param {
  border-bottom: 1px solid #ddd;
  padding: 20px 0;
}

.item-param h5 {
  margin-bottom: 10px;
}

.item-param.quality {
  padding: 10px 0 30px;
}

.item-param.quality h5 {
  margin-bottom: 20px;
}

.item-param input {
  border: 0;
}

.custom-button {
  width: 26px;
  color: #fff;
  font-size: 10px;
  line-height: 18px;
  text-align: center;
  background-color: #2f85da;
  border-radius: 100px;
}

.files-wrapper {
  background-color: #f5f5f5;
}
</style>
